package com.sharp.socket.io.controller;

import com.sharp.kernel.config.response.Response;
import com.sharp.kernel.config.response.ResponseHandler;
import com.sharp.kernel.vo.common.CommonResVO;
import com.sharp.socket.io.service.chat.ChatFriendManageService;
import com.sharp.socket.io.vo.chat.friend.ChatFriendRes;
import com.sharp.socket.io.vo.chat.friend.ConfirmFriendReq;
import com.sharp.socket.io.vo.chat.friend.MakeFriendReq;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;

/**
 * Title: BaseChatFriendController
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2021/2/7 16:44
 * @description Project Name: Seed
 * @Package: com.srct.service.socketio.controller
 */
public class BaseChatFriendController {

    @Resource
    private ChatFriendManageService chatFriendManageService;

    @ApiOperation(value = "获取好友列表", notes = "获取好友列表")
    @RequestMapping(value = "/chat/friend", method = RequestMethod.GET)
    public ResponseEntity<Response<List<ChatFriendRes>>> getFriend() {
        List<ChatFriendRes> res = chatFriendManageService.getFriendList();
        return ResponseHandler.generateResponse(res);
    }

    @ApiOperation(value = "申请添加好友", notes = "申请添加好友")
    @RequestMapping(value = "/chat/friend", method = RequestMethod.POST)
    public ResponseEntity<Response<CommonResVO>> makeFriend(@RequestBody MakeFriendReq req) {
        chatFriendManageService.friend(req);
        return ResponseHandler.commonResponse();
    }

    @ApiOperation(value = "获取添加好友申请列表", notes = "获取添加好友申请列表")
    @RequestMapping(value = "/chat/friend/confirm", method = RequestMethod.GET)
    public ResponseEntity<Response<List<ChatFriendRes>>> getConfirmedFriend() {
        List<ChatFriendRes> res = chatFriendManageService.getUnconfirmedFriend();
        return ResponseHandler.generateResponse(res);
    }

    @ApiOperation(value = "审核添加好友", notes = "审核添加好友")
    @RequestMapping(value = "/chat/friend/confirm", method = RequestMethod.POST)
    public ResponseEntity<Response<CommonResVO>> confirmFriend(@RequestBody ConfirmFriendReq req) {
        chatFriendManageService.confirmFriend(req);
        return ResponseHandler.commonResponse();
    }


}
